package com.jiepu.daily.corejava.advanceed.part6thread.wait;

/**
 * @Description:
 * @author: xinjie.txt
 * @date: 2020/8/3  16:38
 */
public class WaitDemo3 {

	static class Test1 extends Thread{
		Object lock;
		public Test1(String name,Object lock){
			super(name);
			this.lock=lock;
		}

		@Override
		public void run() {
			synchronized (lock){
				System.out.println("456123");

				try {
					System.out.println("wait...");
					lock.wait();
					System.out.println("wait eng...");

				} catch (InterruptedException e) {
					e.printStackTrace();
				}

			}
		}

	} // Test1

	public static void main(String[] args) {

		Object lock = new Object();
		Test1 t1 = new Test1("Thread1",lock);
		Test1 t2 = new Test1("Thread2",lock);

		t1.start();
		t2.start();


	}

}
